<!--
 * @Author: yangzr 1076420747@qq.com
 * @Date: 2022-09-20 17:56:40
 * @LastEditors: yangzr 1076420747@qq.com
 * @LastEditTime: 2022-09-26 17:57:25
 * @FilePath: \ktgj-crm\src\views\vipManager\vipResourceTrace.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="vipResourceTrace">
    <!-- 表格数据 -->
    <el-table class="tableClass" :data="tableData" :header-cell-style="{
        color: '#fff',
        background: '#6090EC',
        fontSize: '11px',
        fontWeight: 'normal',
      }" size="mini" border>
      <el-table-column prop="businessType" label="业务类型">
        <template slot-scope="scope">
          <template v-if="scope.row.businessType == 'flight'">机票</template>
          <template v-if="scope.row.businessType == 'hotel'">酒店</template>
          <template v-if="scope.row.businessType == 'train'">火车票</template>
        </template>
      </el-table-column>
      <el-table-column prop="orderId" label="团类订单号型"> </el-table-column>
      <el-table-column prop="ticketNight" label="票量/间夜数/人量">
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间"> </el-table-column>
      <el-table-column prop="departureCheckin" label="出行时间">
      </el-table-column>
      <el-table-column prop="supplierName" label="出发到达"></el-table-column>
      <el-table-column prop="customerName" label="会员姓名"></el-table-column>
      <el-table-column prop="serviceContent" label="服务内容" width="200"></el-table-column>
      <!-- <el-table-column prop="contractNum" label="跟进记录"></el-table-column> -->
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button slot="reference" type="primary" size="mini" @click="shelves(scope.row)">修改服务内容</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="修改服务内容" :visible.sync="editdialogVisible" width="30%">
      <el-form ref="editfrom" :rules="rules" :model="editfrom" label-width="80px">
        <el-form-item label="服务内容" prop="serviceContent">
          <el-input v-model="editfrom.serviceContent"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editdialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitForm('editfrom')">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "vipResourceTrace",

    data() {
      return {
        // 表格数据
        tableData: [],
        // 服务内容
        editfrom: {
          serviceContent: "",
        },
        rules: {
          serviceContent: [{
            required: true,
            message: "请输入服务内容",
            trigger: "blur"
          }, ],
        },
        //修改服务内容弹窗
        editdialogVisible: false,
        // 修改内容主键
        employeeThingId: "",
      };
    },
    watch: {},

    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.getthingedit();
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      },
      shelves(row) {
        console.log(row);
        this.employeeThingId = row.employeeThingId;
        this.editdialogVisible = true;
        this.editfrom.serviceContent = row.serviceContent;
      },
      //查询待跟进事项
      getthinglist() {
        localStorage.setItem("isToken", true);
        this.$axios.getthinglist({}).then((res) => {
          if (res.code == "200") {
            this.tableData = res.data;
          }
        });
      },
      //修改内容
      getthingedit() {
        this.$axios
          .getthingedit({
            employeeThingId: this.employeeThingId,
            serviceContent: this.editfrom.serviceContent,
          })
          .then((res) => {
            if (res.code == "200") {
              this.editdialogVisible = false;
              this.$message({
                message: "修改成功",
                type: "success",
              });
              this.getthinglist();
            }
          });
      },
    },

    mounted() {
      this.getthinglist();
    },
  };
</script>
<style scoped>
  .tableClass {
    margin: 30px 0 0 10px;
  }
</style>